%  CODE: this code generates Figure 5 in GMMSV											            			
clear;
close all;

%% I. LOAD DATA
% Same names as in STATA data base; imported below and stored as 'matname_names' array
cd .. /data;
FF17mat = csvread('EstimatesbygvkeyandFF17.csv',1,0);

ff10    = FF17mat(:,1);
ff17    = FF17mat(:,2);
mu      = FF17mat(:,3);
sigma_P = FF17mat(:,4);
sigma_A = FF17mat(:,5);
rho     = FF17mat(:,6);

ff17means = grpstats(rho,ff17);

%% II. Set paths and axes labels
% FF labels
ffind10 = {'NonDurables';'Durables';'Manufacturing';'Energy';'TechEq';'Telecom';'Shops';'Healthcare';'Utilities';'Other'};
ffind17 = {'Food';'Mining';'Oil';'Textiles';'Durables';'Chemicals'; ...
           'Consumer';'Construction';'Steel';'Metals';'Machinery'; ...
           'Cars';'Transport';'Utilities';'Retail';'Finance';'Other'};
       
ff17names = []; ff10names = [];
    for f = 1:size(FF17mat,1)
        ff17names = [ff17names;ffind17(FF17mat(f,2))];
        ff10names = [ff10names;ffind10(FF17mat(f,1))];
    end
            
 
%% IV. Figures
fig = 1;
%  IV.1 For paper           
    figure(fig)
    set(fig,'PaperOrientation','landscape');
    set(fig,'Color',[1 1 1]);
        %h1 = boxplot(rho,ff17names,'PlotStyle','compact','Symbol','k.');
        h1 = boxplot(rho,ff17names,'Symbol','k.');
        hold on
        h2 = scatter((min(get(gca,'Xlim'))+0.5:max(get(gca,'Xlim'))-0.5)',ff17means,'*','b');
        h3 = plot(xlim, [0 0],':k');
        legend(h2,'FF17 Industry Mean','Location','south')
        ylim([min(rho)-0.1 max(rho)+0.1])    
        set(gca,'FontSize',10,'XTickLabelRotation',90)
        box('on'); hold off; 
        



